# 项目:
# 文件: demo3
# 作者: Yang
# 日期: 2025/5/23 11:28
# coding:utf-8
import json
from selenium import webdriver


class UIAtion:

    driver = None

    @classmethod
    def get_driver(cls):
        browser = Util.read_json('conf.json')['browser']
        if cls.driver is None:
            if hasattr(webdriver,browser):
                cls.driver = getattr(webdriver,browser)
                cls.driver.implicitly_wait(5)  # 隐式等待
                cls.driver.maximize_window()  # 最大化窗口
            else:
                print("浏览器名称错误")
        return cls.driver


class Util:
    @classmethod
    def read_json(cls, path):
        """
        用于读取指定的json文件，返回json格式的数据
        :param path: json文件的路径和名称
        :return: json格式的数据
        """
        with open(path, encoding='utf-8') as file:
            contents =  json.load(file)
        return contents

if __name__ == '__main__':
    pass